/**
 * 
 */
package com.jonosoft.photocast.viewer.web.client.ui;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.jonosoft.photocast.viewer.web.client.ImageCollection;
import com.jonosoft.photocast.viewer.web.client.ImageCollection.SortOrder;
import com.jonosoft.photocast.viewer.web.client.ImageCollection.SortableFields;
import com.jonosoft.photocast.viewer.web.client.util.Size;

/**
 * TODO Add description ImageBrowser (com.jonosoft.photocast.viewer.web.client.ImageBrowser)
 *
 * @author jon
 *
 */
public class ImageBrowser extends Composite {
	
	private static String STYLE_NAME = "image-browser";
	
	private ImageCollection imageCollection = null;
	private final VerticalPanel panel = new VerticalPanel();
	
	private final ThumbnailsPanel thumbnailsPanel = new ThumbnailsPanel(this, null);
	
	public ImageBrowser() {
		initWidget(panel);
		
		panel.setStyleName(STYLE_NAME);
		
		panel.add(thumbnailsPanel);
	}
	
	public ImageBrowser(ImageCollection imageArray) {
		this();
		
		setImages(imageArray);
	}
	
	public void setImages(ImageCollection imageArray) {
		this.imageCollection = imageArray;
		this.imageCollection.sort(SortableFields.PHOTO_DATE, SortOrder.DESCENDING);
		thumbnailsPanel.setImages(imageArray);
		thumbnailsPanel.populateImageGrid();
	}

	/**
     * TODO Add method description for resize
     *
     * @param size
     */
    public void resize(Size size) {
    	panel.setHeight(size.getCSSHeight());
    	
    	thumbnailsPanel.resize(size);
    }
    
    /*public void startSlideShow(LibraryImageArray imageArray, int startIndex) {
    	
    }*/
	
}
